import http from '../utils/request'
export default{
    userPager:function(data){
        return http.get('/users',data);
    },
    deleteUsers:function(ids){
        return http.delete('/user',{ids:ids});
    },
    getUser:function(id){
        return http.get(`/users/${id}`);
    },
    updateUser:function(data){
        return http.put('/user',data);
    },
    addUser:function(data){
        return http.post('/user',data);
    },
    getUserRoles:function(id){
        return http.get(`/users/${id}/role`);
    },
    updateUserRoles:function(id,roles){
        return http.put(`/users/${id}/role`,{roleIdList:roles});
    },
    resetPwd:function(data){
        return http.put('/user/pwd/reset',data);
    },
    changePwd:function(data){
        return http.post('/user/pwd',data);
    },
    accountExist:function(userId,userAccount){
        return http.put('/user/account/valid',{userId:userId,userAccount:userAccount});
    },
    downloadSourceCode:function(data,cb){
        return http.post('/rename/project/rename',data,
            {
                mockMode:false,
                responseType:'blob',onDownloadProgress: function (progressEvent) {
                    if(cb){
                        cb((100*progressEvent.loaded/progressEvent.total).toFixed(2))
                    }
                }
        })
    }
}
